<?php


abstract class BaseTaxes extends BaseObject  implements Persistent {


  const PEER = 'TaxesPeer';

	
	protected static $peer;

	
	protected $id;

	
	protected $name;

	
	protected $category;

	
	protected $custcategory;

	
	protected $parentid;

	
	protected $rate;

	
	protected $ratecascade;

	
	protected $rateorder;

	
	protected $aTaxcategories;

	
	protected $aTaxcustcategories;

	
	protected $aTaxesRelatedByParentid;

	
	protected $collTaxessRelatedByParentid;

	
	private $lastTaxesRelatedByParentidCriteria = null;

	
	protected $collTaxliness;

	
	private $lastTaxlinesCriteria = null;

	
	protected $collTicketliness;

	
	private $lastTicketlinesCriteria = null;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function __construct()
	{
		parent::__construct();
		$this->applyDefaultValues();
	}

	
	public function applyDefaultValues()
	{
	}

	
	public function getId()
	{
		return $this->id;
	}

	
	public function getName()
	{
		return $this->name;
	}

	
	public function getCategory()
	{
		return $this->category;
	}

	
	public function getCustcategory()
	{
		return $this->custcategory;
	}

	
	public function getParentid()
	{
		return $this->parentid;
	}

	
	public function getRate()
	{
		return $this->rate;
	}

	
	public function getRatecascade()
	{
		return $this->ratecascade;
	}

	
	public function getRateorder()
	{
		return $this->rateorder;
	}

	
	public function setId($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = TaxesPeer::ID;
		}

		return $this;
	} 
	
	public function setName($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->name !== $v) {
			$this->name = $v;
			$this->modifiedColumns[] = TaxesPeer::NAME;
		}

		return $this;
	} 
	
	public function setCategory($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->category !== $v) {
			$this->category = $v;
			$this->modifiedColumns[] = TaxesPeer::CATEGORY;
		}

		if ($this->aTaxcategories !== null && $this->aTaxcategories->getId() !== $v) {
			$this->aTaxcategories = null;
		}

		return $this;
	} 
	
	public function setCustcategory($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->custcategory !== $v) {
			$this->custcategory = $v;
			$this->modifiedColumns[] = TaxesPeer::CUSTCATEGORY;
		}

		if ($this->aTaxcustcategories !== null && $this->aTaxcustcategories->getId() !== $v) {
			$this->aTaxcustcategories = null;
		}

		return $this;
	} 
	
	public function setParentid($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->parentid !== $v) {
			$this->parentid = $v;
			$this->modifiedColumns[] = TaxesPeer::PARENTID;
		}

		if ($this->aTaxesRelatedByParentid !== null && $this->aTaxesRelatedByParentid->getId() !== $v) {
			$this->aTaxesRelatedByParentid = null;
		}

		return $this;
	} 
	
	public function setRate($v)
	{
		if ($v !== null) {
			$v = (double) $v;
		}

		if ($this->rate !== $v) {
			$this->rate = $v;
			$this->modifiedColumns[] = TaxesPeer::RATE;
		}

		return $this;
	} 
	
	public function setRatecascade($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->ratecascade !== $v) {
			$this->ratecascade = $v;
			$this->modifiedColumns[] = TaxesPeer::RATECASCADE;
		}

		return $this;
	} 
	
	public function setRateorder($v)
	{
		if ($v !== null) {
			$v = (int) $v;
		}

		if ($this->rateorder !== $v) {
			$this->rateorder = $v;
			$this->modifiedColumns[] = TaxesPeer::RATEORDER;
		}

		return $this;
	} 
	
	public function hasOnlyDefaultValues()
	{
						if (array_diff($this->modifiedColumns, array())) {
				return false;
			}

				return true;
	} 
	
	public function hydrate($row, $startcol = 0, $rehydrate = false)
	{
		try {

			$this->id = ($row[$startcol + 0] !== null) ? (string) $row[$startcol + 0] : null;
			$this->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
			$this->category = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
			$this->custcategory = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
			$this->parentid = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
			$this->rate = ($row[$startcol + 5] !== null) ? (double) $row[$startcol + 5] : null;
			$this->ratecascade = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
			$this->rateorder = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
			$this->resetModified();

			$this->setNew(false);

			if ($rehydrate) {
				$this->ensureConsistency();
			}

						return $startcol + 8; 
		} catch (Exception $e) {
			throw new PropelException("Error populating Taxes object", $e);
		}
	}

	
	public function ensureConsistency()
	{

		if ($this->aTaxcategories !== null && $this->category !== $this->aTaxcategories->getId()) {
			$this->aTaxcategories = null;
		}
		if ($this->aTaxcustcategories !== null && $this->custcategory !== $this->aTaxcustcategories->getId()) {
			$this->aTaxcustcategories = null;
		}
		if ($this->aTaxesRelatedByParentid !== null && $this->parentid !== $this->aTaxesRelatedByParentid->getId()) {
			$this->aTaxesRelatedByParentid = null;
		}
	} 
	
	public function reload($deep = false, PropelPDO $con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("Cannot reload a deleted object.");
		}

		if ($this->isNew()) {
			throw new PropelException("Cannot reload an unsaved object.");
		}

		if ($con === null) {
			$con = Propel::getConnection(TaxesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}

				
		$stmt = TaxesPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
		$row = $stmt->fetch(PDO::FETCH_NUM);
		$stmt->closeCursor();
		if (!$row) {
			throw new PropelException('Cannot find matching row in the database to reload object values.');
		}
		$this->hydrate($row, 0, true); 
		if ($deep) {  
			$this->aTaxcategories = null;
			$this->aTaxcustcategories = null;
			$this->aTaxesRelatedByParentid = null;
			$this->collTaxessRelatedByParentid = null;
			$this->lastTaxesRelatedByParentidCriteria = null;

			$this->collTaxliness = null;
			$this->lastTaxlinesCriteria = null;

			$this->collTicketliness = null;
			$this->lastTicketlinesCriteria = null;

		} 	}

	
	public function delete(PropelPDO $con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(TaxesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}
		
		$con->beginTransaction();
		try {
			TaxesPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollBack();
			throw $e;
		}
	}

	
	public function save(PropelPDO $con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(TaxesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}
		
		$con->beginTransaction();
		try {
			$affectedRows = $this->doSave($con);
			$con->commit();
			TaxesPeer::addInstanceToPool($this);
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollBack();
			throw $e;
		}
	}

	
	protected function doSave(PropelPDO $con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;

												
			if ($this->aTaxcategories !== null) {
				if ($this->aTaxcategories->isModified() || $this->aTaxcategories->isNew()) {
					$affectedRows += $this->aTaxcategories->save($con);
				}
				$this->setTaxcategories($this->aTaxcategories);
			}

			if ($this->aTaxcustcategories !== null) {
				if ($this->aTaxcustcategories->isModified() || $this->aTaxcustcategories->isNew()) {
					$affectedRows += $this->aTaxcustcategories->save($con);
				}
				$this->setTaxcustcategories($this->aTaxcustcategories);
			}

			if ($this->aTaxesRelatedByParentid !== null) {
				if ($this->aTaxesRelatedByParentid->isModified() || $this->aTaxesRelatedByParentid->isNew()) {
					$affectedRows += $this->aTaxesRelatedByParentid->save($con);
				}
				$this->setTaxesRelatedByParentid($this->aTaxesRelatedByParentid);
			}


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = TaxesPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setNew(false);
				} else {
					$affectedRows += TaxesPeer::doUpdate($this, $con);
				}

				$this->resetModified(); 			}

			if ($this->collTaxessRelatedByParentid !== null) {
				foreach ($this->collTaxessRelatedByParentid as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			if ($this->collTaxliness !== null) {
				foreach ($this->collTaxliness as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			if ($this->collTicketliness !== null) {
				foreach ($this->collTicketliness as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			$this->alreadyInSave = false;

		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


												
			if ($this->aTaxcategories !== null) {
				if (!$this->aTaxcategories->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aTaxcategories->getValidationFailures());
				}
			}

			if ($this->aTaxcustcategories !== null) {
				if (!$this->aTaxcustcategories->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aTaxcustcategories->getValidationFailures());
				}
			}

			if ($this->aTaxesRelatedByParentid !== null) {
				if (!$this->aTaxesRelatedByParentid->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aTaxesRelatedByParentid->getValidationFailures());
				}
			}


			if (($retval = TaxesPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}


				if ($this->collTaxessRelatedByParentid !== null) {
					foreach ($this->collTaxessRelatedByParentid as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}

				if ($this->collTaxliness !== null) {
					foreach ($this->collTaxliness as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}

				if ($this->collTicketliness !== null) {
					foreach ($this->collTicketliness as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}


			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = TaxesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		$field = $this->getByPosition($pos);
		return $field;
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getName();
				break;
			case 2:
				return $this->getCategory();
				break;
			case 3:
				return $this->getCustcategory();
				break;
			case 4:
				return $this->getParentid();
				break;
			case 5:
				return $this->getRate();
				break;
			case 6:
				return $this->getRatecascade();
				break;
			case 7:
				return $this->getRateorder();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
	{
		$keys = TaxesPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getName(),
			$keys[2] => $this->getCategory(),
			$keys[3] => $this->getCustcategory(),
			$keys[4] => $this->getParentid(),
			$keys[5] => $this->getRate(),
			$keys[6] => $this->getRatecascade(),
			$keys[7] => $this->getRateorder(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = TaxesPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setName($value);
				break;
			case 2:
				$this->setCategory($value);
				break;
			case 3:
				$this->setCustcategory($value);
				break;
			case 4:
				$this->setParentid($value);
				break;
			case 5:
				$this->setRate($value);
				break;
			case 6:
				$this->setRatecascade($value);
				break;
			case 7:
				$this->setRateorder($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = TaxesPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setCategory($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setCustcategory($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setParentid($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setRate($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setRatecascade($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setRateorder($arr[$keys[7]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(TaxesPeer::DATABASE_NAME);

		if ($this->isColumnModified(TaxesPeer::ID)) $criteria->add(TaxesPeer::ID, $this->id);
		if ($this->isColumnModified(TaxesPeer::NAME)) $criteria->add(TaxesPeer::NAME, $this->name);
		if ($this->isColumnModified(TaxesPeer::CATEGORY)) $criteria->add(TaxesPeer::CATEGORY, $this->category);
		if ($this->isColumnModified(TaxesPeer::CUSTCATEGORY)) $criteria->add(TaxesPeer::CUSTCATEGORY, $this->custcategory);
		if ($this->isColumnModified(TaxesPeer::PARENTID)) $criteria->add(TaxesPeer::PARENTID, $this->parentid);
		if ($this->isColumnModified(TaxesPeer::RATE)) $criteria->add(TaxesPeer::RATE, $this->rate);
		if ($this->isColumnModified(TaxesPeer::RATECASCADE)) $criteria->add(TaxesPeer::RATECASCADE, $this->ratecascade);
		if ($this->isColumnModified(TaxesPeer::RATEORDER)) $criteria->add(TaxesPeer::RATEORDER, $this->rateorder);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(TaxesPeer::DATABASE_NAME);

		$criteria->add(TaxesPeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setId($this->id);

		$copyObj->setName($this->name);

		$copyObj->setCategory($this->category);

		$copyObj->setCustcategory($this->custcategory);

		$copyObj->setParentid($this->parentid);

		$copyObj->setRate($this->rate);

		$copyObj->setRatecascade($this->ratecascade);

		$copyObj->setRateorder($this->rateorder);


		if ($deepCopy) {
									$copyObj->setNew(false);

			foreach ($this->getTaxessRelatedByParentid() as $relObj) {
				if ($relObj !== $this) {  					$copyObj->addTaxesRelatedByParentid($relObj->copy($deepCopy));
				}
			}

			foreach ($this->getTaxliness() as $relObj) {
				if ($relObj !== $this) {  					$copyObj->addTaxlines($relObj->copy($deepCopy));
				}
			}

			foreach ($this->getTicketliness() as $relObj) {
				if ($relObj !== $this) {  					$copyObj->addTicketlines($relObj->copy($deepCopy));
				}
			}

		} 

		$copyObj->setNew(true);

	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new TaxesPeer();
		}
		return self::$peer;
	}

	
	public function setTaxcategories(Taxcategories $v = null)
	{
		if ($v === null) {
			$this->setCategory(NULL);
		} else {
			$this->setCategory($v->getId());
		}

		$this->aTaxcategories = $v;

						if ($v !== null) {
			$v->addTaxes($this);
		}

		return $this;
	}


	
	public function getTaxcategories(PropelPDO $con = null)
	{
		if ($this->aTaxcategories === null && (($this->category !== "" && $this->category !== null))) {
			$c = new Criteria(TaxcategoriesPeer::DATABASE_NAME);
			$c->add(TaxcategoriesPeer::ID, $this->category);
			$this->aTaxcategories = TaxcategoriesPeer::doSelectOne($c, $con);
			
		}
		return $this->aTaxcategories;
	}

	
	public function setTaxcustcategories(Taxcustcategories $v = null)
	{
		if ($v === null) {
			$this->setCustcategory(NULL);
		} else {
			$this->setCustcategory($v->getId());
		}

		$this->aTaxcustcategories = $v;

						if ($v !== null) {
			$v->addTaxes($this);
		}

		return $this;
	}


	
	public function getTaxcustcategories(PropelPDO $con = null)
	{
		if ($this->aTaxcustcategories === null && (($this->custcategory !== "" && $this->custcategory !== null))) {
			$c = new Criteria(TaxcustcategoriesPeer::DATABASE_NAME);
			$c->add(TaxcustcategoriesPeer::ID, $this->custcategory);
			$this->aTaxcustcategories = TaxcustcategoriesPeer::doSelectOne($c, $con);
			
		}
		return $this->aTaxcustcategories;
	}

	
	public function setTaxesRelatedByParentid(Taxes $v = null)
	{
		if ($v === null) {
			$this->setParentid(NULL);
		} else {
			$this->setParentid($v->getId());
		}

		$this->aTaxesRelatedByParentid = $v;

						if ($v !== null) {
			$v->addTaxesRelatedByParentid($this);
		}

		return $this;
	}


	
	public function getTaxesRelatedByParentid(PropelPDO $con = null)
	{
		if ($this->aTaxesRelatedByParentid === null && (($this->parentid !== "" && $this->parentid !== null))) {
			$c = new Criteria(TaxesPeer::DATABASE_NAME);
			$c->add(TaxesPeer::ID, $this->parentid);
			$this->aTaxesRelatedByParentid = TaxesPeer::doSelectOne($c, $con);
			
		}
		return $this->aTaxesRelatedByParentid;
	}

	
	public function clearTaxessRelatedByParentid()
	{
		$this->collTaxessRelatedByParentid = null; 	}

	
	public function initTaxessRelatedByParentid()
	{
		$this->collTaxessRelatedByParentid = array();
	}

	
	public function getTaxessRelatedByParentid($criteria = null, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TaxesPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collTaxessRelatedByParentid === null) {
			if ($this->isNew()) {
			   $this->collTaxessRelatedByParentid = array();
			} else {

				$criteria->add(TaxesPeer::PARENTID, $this->id);

				TaxesPeer::addSelectColumns($criteria);
				$this->collTaxessRelatedByParentid = TaxesPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(TaxesPeer::PARENTID, $this->id);

				TaxesPeer::addSelectColumns($criteria);
				if (!isset($this->lastTaxesRelatedByParentidCriteria) || !$this->lastTaxesRelatedByParentidCriteria->equals($criteria)) {
					$this->collTaxessRelatedByParentid = TaxesPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastTaxesRelatedByParentidCriteria = $criteria;
		return $this->collTaxessRelatedByParentid;
	}

	
	public function countTaxessRelatedByParentid(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TaxesPeer::DATABASE_NAME);
		} else {
			$criteria = clone $criteria;
		}

		if ($distinct) {
			$criteria->setDistinct();
		}

		$count = null;

		if ($this->collTaxessRelatedByParentid === null) {
			if ($this->isNew()) {
				$count = 0;
			} else {

				$criteria->add(TaxesPeer::PARENTID, $this->id);

				$count = TaxesPeer::doCount($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(TaxesPeer::PARENTID, $this->id);

				if (!isset($this->lastTaxesRelatedByParentidCriteria) || !$this->lastTaxesRelatedByParentidCriteria->equals($criteria)) {
					$count = TaxesPeer::doCount($criteria, $con);
				} else {
					$count = count($this->collTaxessRelatedByParentid);
				}
			} else {
				$count = count($this->collTaxessRelatedByParentid);
			}
		}
		$this->lastTaxesRelatedByParentidCriteria = $criteria;
		return $count;
	}

	
	public function addTaxesRelatedByParentid(Taxes $l)
	{
		if ($this->collTaxessRelatedByParentid === null) {
			$this->initTaxessRelatedByParentid();
		}
		if (!in_array($l, $this->collTaxessRelatedByParentid, true)) { 			array_push($this->collTaxessRelatedByParentid, $l);
			$l->setTaxesRelatedByParentid($this);
		}
	}


	
	public function getTaxessRelatedByParentidJoinTaxcategories($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TaxesPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collTaxessRelatedByParentid === null) {
			if ($this->isNew()) {
				$this->collTaxessRelatedByParentid = array();
			} else {

				$criteria->add(TaxesPeer::PARENTID, $this->id);

				$this->collTaxessRelatedByParentid = TaxesPeer::doSelectJoinTaxcategories($criteria, $con, $join_behavior);
			}
		} else {
									
			$criteria->add(TaxesPeer::PARENTID, $this->id);

			if (!isset($this->lastTaxesRelatedByParentidCriteria) || !$this->lastTaxesRelatedByParentidCriteria->equals($criteria)) {
				$this->collTaxessRelatedByParentid = TaxesPeer::doSelectJoinTaxcategories($criteria, $con, $join_behavior);
			}
		}
		$this->lastTaxesRelatedByParentidCriteria = $criteria;

		return $this->collTaxessRelatedByParentid;
	}


	
	public function getTaxessRelatedByParentidJoinTaxcustcategories($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TaxesPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collTaxessRelatedByParentid === null) {
			if ($this->isNew()) {
				$this->collTaxessRelatedByParentid = array();
			} else {

				$criteria->add(TaxesPeer::PARENTID, $this->id);

				$this->collTaxessRelatedByParentid = TaxesPeer::doSelectJoinTaxcustcategories($criteria, $con, $join_behavior);
			}
		} else {
									
			$criteria->add(TaxesPeer::PARENTID, $this->id);

			if (!isset($this->lastTaxesRelatedByParentidCriteria) || !$this->lastTaxesRelatedByParentidCriteria->equals($criteria)) {
				$this->collTaxessRelatedByParentid = TaxesPeer::doSelectJoinTaxcustcategories($criteria, $con, $join_behavior);
			}
		}
		$this->lastTaxesRelatedByParentidCriteria = $criteria;

		return $this->collTaxessRelatedByParentid;
	}

	
	public function clearTaxliness()
	{
		$this->collTaxliness = null; 	}

	
	public function initTaxliness()
	{
		$this->collTaxliness = array();
	}

	
	public function getTaxliness($criteria = null, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TaxesPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collTaxliness === null) {
			if ($this->isNew()) {
			   $this->collTaxliness = array();
			} else {

				$criteria->add(TaxlinesPeer::TAXID, $this->id);

				TaxlinesPeer::addSelectColumns($criteria);
				$this->collTaxliness = TaxlinesPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(TaxlinesPeer::TAXID, $this->id);

				TaxlinesPeer::addSelectColumns($criteria);
				if (!isset($this->lastTaxlinesCriteria) || !$this->lastTaxlinesCriteria->equals($criteria)) {
					$this->collTaxliness = TaxlinesPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastTaxlinesCriteria = $criteria;
		return $this->collTaxliness;
	}

	
	public function countTaxliness(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TaxesPeer::DATABASE_NAME);
		} else {
			$criteria = clone $criteria;
		}

		if ($distinct) {
			$criteria->setDistinct();
		}

		$count = null;

		if ($this->collTaxliness === null) {
			if ($this->isNew()) {
				$count = 0;
			} else {

				$criteria->add(TaxlinesPeer::TAXID, $this->id);

				$count = TaxlinesPeer::doCount($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(TaxlinesPeer::TAXID, $this->id);

				if (!isset($this->lastTaxlinesCriteria) || !$this->lastTaxlinesCriteria->equals($criteria)) {
					$count = TaxlinesPeer::doCount($criteria, $con);
				} else {
					$count = count($this->collTaxliness);
				}
			} else {
				$count = count($this->collTaxliness);
			}
		}
		$this->lastTaxlinesCriteria = $criteria;
		return $count;
	}

	
	public function addTaxlines(Taxlines $l)
	{
		if ($this->collTaxliness === null) {
			$this->initTaxliness();
		}
		if (!in_array($l, $this->collTaxliness, true)) { 			array_push($this->collTaxliness, $l);
			$l->setTaxes($this);
		}
	}

	
	public function clearTicketliness()
	{
		$this->collTicketliness = null; 	}

	
	public function initTicketliness()
	{
		$this->collTicketliness = array();
	}

	
	public function getTicketliness($criteria = null, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TaxesPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collTicketliness === null) {
			if ($this->isNew()) {
			   $this->collTicketliness = array();
			} else {

				$criteria->add(TicketlinesPeer::TAXID, $this->id);

				TicketlinesPeer::addSelectColumns($criteria);
				$this->collTicketliness = TicketlinesPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(TicketlinesPeer::TAXID, $this->id);

				TicketlinesPeer::addSelectColumns($criteria);
				if (!isset($this->lastTicketlinesCriteria) || !$this->lastTicketlinesCriteria->equals($criteria)) {
					$this->collTicketliness = TicketlinesPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastTicketlinesCriteria = $criteria;
		return $this->collTicketliness;
	}

	
	public function countTicketliness(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TaxesPeer::DATABASE_NAME);
		} else {
			$criteria = clone $criteria;
		}

		if ($distinct) {
			$criteria->setDistinct();
		}

		$count = null;

		if ($this->collTicketliness === null) {
			if ($this->isNew()) {
				$count = 0;
			} else {

				$criteria->add(TicketlinesPeer::TAXID, $this->id);

				$count = TicketlinesPeer::doCount($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(TicketlinesPeer::TAXID, $this->id);

				if (!isset($this->lastTicketlinesCriteria) || !$this->lastTicketlinesCriteria->equals($criteria)) {
					$count = TicketlinesPeer::doCount($criteria, $con);
				} else {
					$count = count($this->collTicketliness);
				}
			} else {
				$count = count($this->collTicketliness);
			}
		}
		$this->lastTicketlinesCriteria = $criteria;
		return $count;
	}

	
	public function addTicketlines(Ticketlines $l)
	{
		if ($this->collTicketliness === null) {
			$this->initTicketliness();
		}
		if (!in_array($l, $this->collTicketliness, true)) { 			array_push($this->collTicketliness, $l);
			$l->setTaxes($this);
		}
	}


	
	public function getTicketlinessJoinTickets($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TaxesPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collTicketliness === null) {
			if ($this->isNew()) {
				$this->collTicketliness = array();
			} else {

				$criteria->add(TicketlinesPeer::TAXID, $this->id);

				$this->collTicketliness = TicketlinesPeer::doSelectJoinTickets($criteria, $con, $join_behavior);
			}
		} else {
									
			$criteria->add(TicketlinesPeer::TAXID, $this->id);

			if (!isset($this->lastTicketlinesCriteria) || !$this->lastTicketlinesCriteria->equals($criteria)) {
				$this->collTicketliness = TicketlinesPeer::doSelectJoinTickets($criteria, $con, $join_behavior);
			}
		}
		$this->lastTicketlinesCriteria = $criteria;

		return $this->collTicketliness;
	}


	
	public function getTicketlinessJoinProducts($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		if ($criteria === null) {
			$criteria = new Criteria(TaxesPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collTicketliness === null) {
			if ($this->isNew()) {
				$this->collTicketliness = array();
			} else {

				$criteria->add(TicketlinesPeer::TAXID, $this->id);

				$this->collTicketliness = TicketlinesPeer::doSelectJoinProducts($criteria, $con, $join_behavior);
			}
		} else {
									
			$criteria->add(TicketlinesPeer::TAXID, $this->id);

			if (!isset($this->lastTicketlinesCriteria) || !$this->lastTicketlinesCriteria->equals($criteria)) {
				$this->collTicketliness = TicketlinesPeer::doSelectJoinProducts($criteria, $con, $join_behavior);
			}
		}
		$this->lastTicketlinesCriteria = $criteria;

		return $this->collTicketliness;
	}

	
	public function clearAllReferences($deep = false)
	{
		if ($deep) {
			if ($this->collTaxessRelatedByParentid) {
				foreach ((array) $this->collTaxessRelatedByParentid as $o) {
					$o->clearAllReferences($deep);
				}
			}
			if ($this->collTaxliness) {
				foreach ((array) $this->collTaxliness as $o) {
					$o->clearAllReferences($deep);
				}
			}
			if ($this->collTicketliness) {
				foreach ((array) $this->collTicketliness as $o) {
					$o->clearAllReferences($deep);
				}
			}
		} 
		$this->collTaxessRelatedByParentid = null;
		$this->collTaxliness = null;
		$this->collTicketliness = null;
			$this->aTaxcategories = null;
			$this->aTaxcustcategories = null;
			$this->aTaxesRelatedByParentid = null;
	}

} 